Skip to content

Add VineJS Validator Generation#4

Merged
tomgobich merged 2 commits intoadocasts:mainfrom
tky0065:enokdev
Jun 23, 2025
Merged

Add VineJS Validator Generation#4
tomgobich merged 2 commits intoadocasts:mainfrom
tky0065:enokdev

Conversation

@tky0065
Copy link
Contributor

@tky0065 tky0065 commented Jun 17, 2025

This PR adds VineJS validator generation functionality to the @adocasts.com/dto package. It allows users to generate validators based on model properties, similar to how DTOs are currently generated.

Features Added

  • New ValidatorService class for mapping model properties to VineJS validator types
  • New Ace commands:
    • make:validators - Generate a single validator from a model
    • generate:validators - Generate validators for all models
  • Integration with existing DTO generation:
    • Added --validator flag to make:dto command
    • Added --validator flag to generate:dtos command
  • Validator stub templates:
    • main.stub for model-based validators
    • plain.stub for validators without models
  • Comprehensive test suite for validator generation
  • Updated documentation with examples and usage instructions

Implementation Details

  • Model property types are mapped to appropriate VineJS validator types
  • Optional properties are properly handled with .optional() modifier
  • Relationships are mapped to vine.object() or vine.array() as appropriate
  • DateTime properties are converted to vine.string().datetime()
  • Validators are stored in the app/validators directory

Testing

All functionality has been thoroughly tested with:

  • Unit tests for the ValidatorService
  • Command tests for make:validator and generate:validators
  • Integration tests for DTO and validator generation together

Documentation

  • Added validator generation documentation to README.md
  • Added examples of using generated validators
  • Documented the mapping between model properties and validator rules
  • Created validator_architecture.md with detailed design information

@tomgobich tomgobich merged commit 46b1db4 into adocasts:main Jun 23, 2025
4 of 8 checks passed
@tomgobich
Copy link
Member

tomgobich commented Jun 23, 2025

Thanks so much for taking the time to put this together @tky0065, greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants